#include <iostream>
using namespace std;
const int N = 1e6 + 10;

int a[N];
int tmp[N];
int n;
int ret = 0;

int dfs(int l, int r)
{
	if (l >= r) return 0;
	
	int mid = (l+r)/2;
	dfs(l, mid);
	dfs(mid+1, r);
	
	int cur1 = l, cur2 = mid+1, i = l;
	while(cur1 <= mid && cur2 <= r)
	{
		if (a[cur1] <= a[cur2])
		{
			tmp[i++] = a[cur1++];
		}
		else
		{
			ret += mid-cur1+1;
			tmp[i++] = a[cur2++];
		}
	}
	
	while(cur1 <= mid)
	{
		tmp[i++] = a[cur1++];
	}
	while(cur2 <= r)
	{
		tmp[i++] = a[cur2++];
	}
	
	for (int i = l; i <= r; i++) a[i] = tmp[i];
	
	return 0;
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	
	dfs(1, n);
	
	cout << ret << endl;
	
	return 0;
}
